package com.iring.controller.admin;

import java.util.List;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.iring.controller.BaseController;
import com.iring.domain.common.OpenedServices;
import com.iring.vo.common.BooleanResultVO;
import com.iring.vo.common.device.MacVO;

/**
 * 集团组网服务信息Controller
 *
 * @author wanggan
 */
@RestController
@RequestMapping(value = "/admin/group-network", produces = { "application/json;charset=UTF-8" })
public class GroupNetworkController extends BaseController {

    /**
     * 创建集团组网的服务
     *
     * @param macVO
     *            {@link MacVO}
     * @return 创建结果
     */
    @RequestMapping(value = "/add-group-network", method = RequestMethod.POST)
    public BooleanResultVO addGroupNetwork(@RequestBody MacVO macVO) {
        String username =  getUserSession().getUsername();
        Boolean result = selectService.addGroupNetwork(macVO,username);
        logService.saveLog(username,"add-group-network",getUserRealIp(),true);
        return new BooleanResultVO(result);
    }

    /**
     * 用户开通集团组网的话机列表
     *
     * @return 用户开通集团组网的话机列表
     */
    @RequestMapping(value = "/list-all-group-network", method = RequestMethod.POST)
    public List<OpenedServices> listAllGroupNetwork() {
        return selectService.listAllGroupNetwork(getUserSession().getUsername());
    }

    /**
     * 退订集团组网
     *
     * @param macVO
     *            {@link MacVO}
     * @return 退订结果
     */
    @RequestMapping(value = "/delete-group-network", method = RequestMethod.POST)
    public BooleanResultVO deleteGroupNetwork(@RequestBody MacVO macVO) {
        String username =  getUserSession().getUsername();
        Boolean result = selectService.deleteGroupNetwork(macVO,username);
        logService.saveLog(username,"delete-group-network",getUserRealIp(),true);
        return new BooleanResultVO(result);
    }

}
